
*********************************
*	Author: Rithika Kumar	    *
*    Figure A5                  *
* Setting up data to make figure*	            
*********************************

** Set working directory to "JOP Replication files" folder 

use  "DATA FILES TO SHARE/data_for_analysis_RK_controls.dta", clear

rename mob_govt_ever_index govtvisit
rename claim_contact_welfare_index claim_making 
rename claim_procedure_index claim_procedure
rename claim_contact_problem claim_prob


***** Regression for Joint Familiy ****

foreach i in govtvisit civic_index claim_procedure claim_prob {
    
 quietly   reg `i' i.mig_dummy##i.joint_fam_correct i.caste i.household_inc i.religion edu1 edu2 edu3 edu4 edu5 i.own_inc agri_land_own_acre agri_land_leasein_acre, vce(cluster block_not_mig_list)
    
    // Calculate margins
    margins i.mig_dummy##i.joint_fam_correct
    tempfile jointfam_`i'
margins i.mig_dummy##i.joint_fam_correct, saving("`jointfam_`i''")
   
}

use `jointfam_govtvisit', clear
list
append using `jointfam_civic_index' `jointfam_claim_procedure' `jointfam_claim_prob'

tab _term, nolabel
keep if _term == 3

gen Family = .
replace Family =  2 if _m1 == 0 & _m2 == 0
replace Family =  1 if _m1 == 0 & _m2 == 1
replace Family =  4 if _m1 == 1 & _m2 == 0
replace Family =  3 if _m1 == 1 & _m2 == 1

label define fam 1 "All" 2 "Only husband" 3 "Only in-laws" 4 "None"  
label values Family fam

gen group = .
replace group = 1 in 1/4
replace group = 2 in 5/8
replace group = 3 in 9/12
replace group = 4 in 13/16

gen order = . 
replace order = 1 if Family == 1
replace order = 2 if Family == 2
replace order = 3 if Family == 3
replace order = 4 if Family == 4

keep _margin _se_margin _ci_lb _ci_ub Family group order
rename (_margin _se_margin _ci_lb _ci_ub) (mean se cl cu)

  
label values group vars

save "DATA FILES TO SHARE/TEMP_FILES/Fig_A5.dta", replace
